package cn.tedu;

import sun.management.VMOptionCompositeData;

public class Test4 {
    public static void main(String[] args) {
        My1Thread t=new My1Thread();
        My1Thread t1=new My1Thread();
        My1Thread t2=new My1Thread();
        My1Thread t3=new My1Thread();
        t.setName("谢");
        t1.setName("郜");
        t2.setName("晨");
        t3.setName("晨晨");
        t.start();
        t1.start();
        t2.start();
        t3.start();
    }
}
class My1Thread extends  Thread {
    //静态资源
    // 随着类的加载而加载，优先于对象加载
    //只加载一次，就会一直存在，不再开辟新空间
    //全局唯一，全局共享
    static  int a = 100;

    @Override
    public void run() {
        while (true) {
            if(a>0){
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(super.getName()+"~~~~"+a);
            }else{
                break;
            }
            a--;

        }
    }
}